Repository navigation
fix(providers): tolerate null tool_calls in OpenAI-compatible responses - #144
Conversation
Some OpenAI-compatible hosts (e.g. SGLang) send "tool_calls": null instead of omitting the field. Serde's #[serde(default)] only fills missing keys, so deserialization failed with 'invalid type: null, expected a sequence' on every request. Treat an explicit null as an empty tool-call list in both the non-streaming (ChatMessage) and streaming (ChunkDelta) paths. Backward compatible: missing keys still default to empty.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 53 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Summary
Some OpenAI-compatible inference hosts (e.g. SGLang) send
"tool_calls": nullin chat-completion responses instead of omitting the field. Serde's#[serde(default)]only substitutes a value for missing keys, so an explicitnullfailed deserialization with:This broke every request (plain prompts and tool calls, streaming and non-streaming) against those hosts, including local SGLang deployments of Qwen3.
Fix
Treat an explicit
nullas "no tool calls" (empty list) in both response paths:ChatMessage.tool_calls(non-streaming)ChunkDelta.tool_calls(streaming)via a small generic helper
deser_null_as_empty_seq. Fully backward compatible — missing keys still default to empty, and real tool-call arrays deserialize as before.Verification
cargo test -p code-providers --lib— 76/76 passcargo fmt --checkandcargo clippy -p code-providers --libcleanQwen/Qwen3.8-27B:pongread_filetool call → file read and version returnedpongSummary by CodeRabbit
nullas empty, preventing deserialization errors for both standard and streaming responses.